{{--
/**
 * Created by PhpStrom
 * User: 郭碧云
 * Date: 2021/7/12 14:38
 * Desc:
 */--}}
@extends("layout.admin")

@section("title")
    分类列表
@endsection

@section("content")
    {{--修改样式--}}
    <link href="{{asset('css/table.css')}}" rel="stylesheet"/>
    {{--列表--}}
    <div class="layui-card-body">
        <script type="text/html" id="toolbar">
            {{--添加--}}
            @if(_can("admin.questionType.create"))
            <div class="layui-inline layui-show-xs-block">
                <a onclick="admin.openLayerForm('{{ route("admin.questionType.create") }}', '添加试题分类', 'POST', '500px', '520px',0,'#question_type_from')"
                   class="layui-btn layui-btn-sm" data-type="auto" id="create"><i class="layui-icon"></i>添加</a>
            </div>
            @endif
        </script>
        <table class="layui-table" lay-filter="table-button" lay-data="{toolbar: '#toolbar',defaultToolbar:['filter'], limit:  {{$types['per_page']}} }">
            <thead>
            <tr>
                <th lay-data="{field:'id',width:80, fixed: 'left', unresize: true, sort: true}">编号</th>
                <th lay-data="{field:'name'}">名称</th>
                <th lay-data="{field:'real_name'}">题型</th>
                <th lay-data="{field:'email'}">选项分类</th>
                <th lay-data="{field:'op',fixed: 'right', width:150, align:'center'}">操作</th>
            </tr>
            </thead>
            <tbody>
            @foreach ($types["data"] as $type)
                <tr>
                    <td>{{ $type['id'] }}
                    </td>
                    <td>{{ $type['name'] }}</td>
                    <td>{{$type['type']==0?'未选择':Code::name('QUESTION_TYPE',$type['type'])}}</td>
                    <td>{!! $type['choice_type']==0?'无需选择':Code::name('CHOICE_TYPE',$type['choice_type']) !!}</td>
                    <td data-field="controller">
                            <a class="layui-btn layui-btn-xs" onclick="admin.openLayerForm('{{route('admin.questionType.update',['id'=>$type['id']])}}','修改题型','POST','500px','520px',0,'#question_type_edit')">编辑</a>
                            <a class="layui-btn layui-btn-xs" onclick="admin.tableDataDelete('{{route('admin.questionType.destroy',['id'=>$type['id']])}}',this,'是否删除该分类')">删除</a>
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
        @include("layout.page")
    </div>
@endsection

@section('script')
    <script>
        layui.use([ 'table'], function () {
            var table = layui.table;

            //分页显示
            admin.paginate("{{ $types['total'] }}", "{{ $types['current_page'] }}", "{{ $types['per_page'] }}");
        });
    </script>

    <script src="{{asset('js/layCommon.js')}}"></script>
@endsection
